package cn.action;

public class CollideAction {
    private int x;
    private int y;
    private int width;
    private int height;
    public CollideAction(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }
    public int getXMin(){
        return x - width / 2;
    }
    public int getYMin(){
        return y - height / 2;
    }
    public int getXMax(){
        return x + width / 2;
    }
    public int getYMax(){
        return y + height / 2;
    }
    public void setX(int x){
        this.x = x;

    }
    public void setY(int y) {
        this.y = y;

    }

    public void setWidth(int width) {
        this.width = width;
    }
    public void setHeight(int height) {
        this.height = height;
    }
    public boolean intersects(CollideAction other) {
        return !(getXMax() < other.getXMin() ||
                getXMin() > other.getXMax() ||
                getYMax() < other.getYMin() ||
                getYMin() > other.getYMax());
    }
}
